Page({
  data: {
    activeCode: '',
    popupShowIsok: false,
    DataDay: wx.$util.formatYMD(new Date()),// 当前时间年月日
    showdataTimeCode: 'date',
    DataDayTime: new Date().getTime(),
  },
  onLoad (option) {
    // 单据类型
    let p1 = this.postDataQuery_dynamic({ "table_id": "e_zuche_danjuleixing", "oby": "e_zuche_danjuleixing.row_id", "page": 1, "limit": 20 })
    // 订单状态
    let p2 = this.postDataQuery_dynamic({ "table_id": "e_dingdanzhuangtaibiao", "oby": "e_dingdanzhuangtaibiao.row_id", "page": 1, "limit": 20 })
    // 选择任务类型
    let p3 = this.postDataQuery_dynamic({ "table_id": "e_zuche_zuchefangshi", "oby": "e_zuche_zuchefangshi.row_id", "page": 1, "limit": 20 })
    //  选择派车类型
    let p4 = this.postDataQuery_dynamic({ "table_id": "e_zuche_paicheleixingbiao", "oby": "e_zuche_paicheleixingbiao.row_id", "page": 1, "limit": 20 })
    // 会计期
    let p5 = this.postDataQuery_dynamic({ "table_id": "all_account_period", "oby": "all_account_period.row_id", "page": 1, "limit": 10, "SearchWhere": { "type": "and", "filters": [{ "CompareWith": "account_state", "Operator": "=", "CompareValue": "处理", "or": 0 }] } })
    // 结算方式
    let p6 = this.postDataQuery_dynamic({ "table_id": "e_jiesuanfangshibiao", "oby": "e_jiesuanfangshibiao.row_id", "page": 1, "limit": 20 })
    Promise.allSettled([p1, p2, p3, p4, p5, p6]).then(res => {
      console.log(res, '是啥啊离开')
      // 单据类型
      if (res[0].status != "fulfilled" || res[0].value.errcode != 0 || res[0].value.response.errcode != 0) return wx.$toast(res[0].value.response ? res[0].value.response.errmsg : '单据类型获取失败')
      let danjuValue = res[0].value;
      if (danjuValue.data && danjuValue.data.row && danjuValue.data.row.length > 0) {
        let row = danjuValue.data.row, danjuleixingList = [], danjuleixingId = [];
        row.forEach(element => {
          danjuleixingList.push(element.danjuleixing);
          danjuleixingId.push(element.row_id)
        })
        this.setData({ danjuleixingList, danjuleixingId })
      }

      // 订单状态
      if (res[1].status != "fulfilled" || res[1].value.errcode != 0 || res[1].value.response.errcode != 0) return wx.$toast(res[1].value.response ? res[1].value.response.errmsg : '订单状态获取失败')
      let dingdanValue = res[0].value;
      if (dingdanValue.data && dingdanValue.data.row && dingdanValue.data.row.length > 0) {
        let row = dingdanValue.data.row, dingdanStateList = [], dingdanStateId = [];
        row.forEach(element => {
          dingdanStateList.push(element.dingdanzhuangtai);
          dingdanStateId.push(element.row_id)
        })
        this.setData({ dingdanStateList, dingdanStateId })
      }

      // 选择任务类型
      if (res[2].status != "fulfilled" || res[2].value.errcode != 0 || res[2].value.response.errcode != 0) return wx.$toast(res[2].value.response ? res[2].value.response.errmsg : '选择任务类型获取失败')
      let renwuValue = res[0].value;
      if (renwuValue.data && renwuValue.data.row && renwuValue.data.row.length > 0) {
        let row = renwuValue.data.row, renwuList = [], renwuId = [];
        row.forEach(element => {
          renwuList.push(element.zuchefangshimingchen);
          renwuId.push(element.renwuleixingbianhao)
        })
        this.setData({ renwuList, renwuId })
      }

      // 选择派车类型
      if (res[3].status != "fulfilled" || res[3].value.errcode != 0 || res[3].value.response.errcode != 0) return wx.$toast(res[3].value.response ? res[3].value.response.errmsg : '选择派车类型获取失败')
      let paicheValue = res[0].value;
      if (paicheValue.data && paicheValue.data.row && paicheValue.data.row.length > 0) {
        let row = paicheValue.data.row, paicheList = [], paicheId = [];
        row.forEach(element => {
          paicheList.push(element.paicheleixingmingchen);
          paicheId.push(element.paicheleixingbianhao)
        })
        this.setData({ paicheList, paicheId })
      }
      // 会计期
      if (res[4].status != "fulfilled" || res[4].value.errcode != 0 || res[4].value.response.errcode != 0) return wx.$toast(res[4].value.response ? res[4].value.response.errmsg : '会计期获取失败')
      let periodValue = res[0].value;
      if (periodValue.data && periodValue.data.row && periodValue.data.row.length > 0) {
        let row = periodValue.data.row, periodList = [], periodId = [];
        row.forEach(element => {
          periodList.push(element.account_period);
          periodId.push(element.rowId)
        })
        this.setData({ periodList, periodId })
      }

      // 结算方式
      if (res[5].status != "fulfilled" || res[5].value.errcode != 0 || res[5].value.response.errcode != 0) return wx.$toast(res[5].value.response ? res[5].value.response.errmsg : '结算方式获取失败')
      let jiesuanValue = res[0].value;
      if (jiesuanValue.data && jiesuanValue.data.row && jiesuanValue.data.row.length > 0) {
        let row = jiesuanValue.data.row, jiesuanList = [], jiesuanId = [];
        row.forEach(element => {
          jiesuanList.push(element.jiesuanfangshi);
          jiesuanId.push(element.row_id)
        })
        this.setData({ jiesuanList, jiesuanId })
      }
    })
  },
  onShow () {
  },
  Payment () {
    // 支付
    // wx.requestPayment({
    //   timeStamp: paymentData?.timeStamp,
    //   nonceStr: paymentData?.nonceStr,
    //   package: paymentData?.packageVal,
    //   paySign: paymentData?.paySign,
    //   signType: "RSA", // 该参数为固定值
    //   success(res) {
    //     // 支付成功回调，实现自定义的业务逻辑
    //     console.log('唤起支付组件成功：', res);
    //   },
    //   fail(err) {
    //     // 支付失败回调
    //     console.error('唤起支付组件失败：', err);
    //   }
    // });
  },
  openLocation () {
    // 打开地图查看位置
    let locationObj = {
      latitude: '',
      longitude: '',
      name: '',
      address: ''
    }
    wx.openLocation({
      ...locationObj,
      complete (res) {
        console.log(res, '查看信息呢')
      }
    })
  },
  showModal (e) {
    this.setData({ popupShow: true, popupCode: e.target.dataset.code })
  },
  onChangeRadio (e) {
    this.setData({ explainIsok: true })
  },
  onClose () {
    this.setData({ popupShow: false })
  },
  onSubmit () {
    let postData = {
      "table": {
        "table_id": "e_zuche_zuchedan",
        "entitys": [
          {
            "entity": {
              // "zhangtaohesuanquyu": 5,
              "Order_date": Order_date,
              // "hetongmingchen": 14,
              // "danjuleixingyinyong": 1, // 1是班线租车单 2是旅游租车单
              "dingdanzhuangtai": 1,
              "Order_client_ID": 12,
              // "kehudanweiquanchen": "佛山市金旅旅游集团有限公司",
              "kehudanweilianxiren": "小黑",
              "kehudanweilianxirenshouji": "13690147852",
              // "kehudizhi": "佛山市禅城区季华隧道与文华北路交叉路口往西南约200米",
              "yongcheriqi": "2024-07-17",
              "yongcheshijian": "2024-07-17 00:00:00",
              "zuchetianshu": "1.00",
              "jieshuriqi": "2024-07-17",
              "quchengqidian": "佛山市禅城区人民政府",
              "quchengtujingdian": "中山公园,佛山汽车站",
              "quchengqidi": "光明花半里",
              "huichengqidian": null,
              "huichengtujingdian": null,
              "huichengqidi": null,
              "xuanzerenwuleixing": 1, // 1是单程 2是双程
              "shifuyuquchengxiangtong": 0,
              "xuanzepaicheleixing": 1,// 1是单次排车 2是按日排车
              // "account_period": 202407,
              "xuanzejiesuanfangshi": 8,
              "beizhu": "你好我是测试租车单的信息2222",
              // "suoshupianqubianhao": 2,
              // "shangchedianlicheng": "6.000",
              // "quchengzonglicheng": "16.000",
              // "huichengzonglicheng": "0.000",
              // "julizonglicheng": "16.000",
              // "shouchedianlicheng": "9.000",
              // "yugujifeilicheng": "22.000",
              // "youhuilicheng": "0",
              // "zhixingjifeilicheng": "22.000",
              // "shifukaipiao": 0,
              // "fapiaotaitou": null,
              // "nashuirenshibiehao": null,
              // "kaihuyinxing": null,
              // "yinxingzhanghao": null,
              // "kaipiaobeizhu": "佛山市金旅旅游集团有限公司",
              // "shifubaohanluqiaofei": 0,
              // "shifubaohanjiayoufei": 0,
              // "shifubaohantingchefei": 0,
              // "shifubaohanzhusufei": 0,
              // "shifubaohancanfei": 0,
              // "shifubaohancanbu": 0,
              // "shifubaohankuangquanshuifei": 0,
              // "shifubaohanqitafei": 0,
              // "shuilv": "8",
              "row_id": "0",
              "renwuleixingbianhao": "0",
              "zuchefangshimingchen": "单程",
              "paicheleixingbianhao": "0",
              "paicheleixingmingchen": "单次排车",
              "jiesuanfangshimingchen": "全款",
              "jiesuanfangshibianhao": "0",
              "danjuleixingbianhao": "1",
              "danjuleixingmingchen": "班线租车单",
              "suoshupianqujingdu": "113.1108",
              "suoshupianqumingchen": "南海区",
              "suoshupianquweidu": "23.0415",
              "quchengqidiandizhi": "广东省佛山市禅城区岭南大道北80号",
              "quchengqidianweidu": 23.009366,
              "quchengqidianjingdu": 113.122506,
              "quchengqidianqubianhao": "440604",
              "quchengqidianshengmingchen": "广东省",
              "quchengqidianshimingchen": "佛山市",
              "quchengqidianqumingchen": "禅城区",
              "quchengqidianshengbianhao": null,
              "quchengqidianshibianhao": null,
              "quchengtujingdianjingweidu": "[{\"name\":\"中山公园\",\"longitude\":113.115791,\"latitude\":23.045332,\"address\":\"广东省佛山市禅城区河滨路12号\"},{\"name\":\"佛山汽车站\",\"longitude\":113.110821,\"latitude\":23.04145,\"address\":\"广东省佛山市禅城区汾江中路6号\"}]",
              "quchengqididizhi": "广东省佛山市南海区罗村大道南1号",
              "quchengqidiweidu": 23.047987,
              "quchengqidijingdu": 113.046946,
              "quchengqidiqubianhao": 440605,
              "quchengqidishengmingchen": "广东省",
              "quchengqidishimingchen": "佛山市",
              "quchengqidiqumingchen": "南海区",
              "quchengqidishengbianhao": null,
              "quchengqidishibianhao": null,
              "huichengtujingdianjingweidu": null,
              "huichengqidiandizhi": null,
              "huichengqidianweidu": null,
              "huichengqidianjingdu": null,
              "huichengqidianqubianhao": null,
              "huichengqidianshengmingchen": null,
              "huichengqidianshimingchen": null,
              "huichengqidianqumingchen": null,
              "huichengqidianshengbianhao": null,
              "huichengqidianshibianhao": null,
              "huichengqididizhi": null,
              "huichengqidiweidu": null,
              "huichengqidijingdu": null,
              "huichengqidiqubianhao": null,
              "huichengqidishengmingchen": null,
              "huichengqidishimingchen": null,
              "huichengqidiqumingchen": null,
              "huichengqidishengbianhao": null,
              "huichengqidishibianhao": null,
              // "hetongdanhao": "HT2023-05-28-000001",
              // "kehudanweibianhao": "YC0003",
              // "kehuleixingbianhao": "2",
              // "kehuleibiebianhao": "3",
              // "kehuhesuanquyu": "5",
              // "kehudianhua": null,
              // "kehuleibiemingchen": "普通客户",
              // "kehuleixingmingchen": "企业客户"
            },
            "details": []
          }
        ]
      }
    }
    wx.$post(3, 'DynamicUpdate/dynamic_update_v3', postData).then(res => {
      console.log(res, '查看一下呢')
    })
  },
  passingPoints () {
    console.log(1)
  },
  ruduceLocationress () {
    console.log(2)
  },
  onChangeCheckBox (e) {
    console.log(e, '查看多选框')
  },
  onChangeCollapse (e) {
    console.log(e, '\查看山东科技阿里')
  },
  dataTimeConfirm (e) {
    let detail = e.detail, { activeCode } = this.data;
    // 时间戳
    if (activeCode == 'zuchedanData') {

    }
  },
  onCloseDateTime () {
    this.setData({ popupShowIsok: false })
  },
  showPopup (e) {
    let { code } = e.currentTarget.dataset
    if (code == 'zuchedanData') {
      this.setData({
        popupShowIsok: true,
        showdataTimeCode: 'date',
        activeCode: code
      })
    }
    if (code == 'danjuleixing') {
      this.setData({
        popupShowIsok: true,
        activeCode: code,
        columns: this.data.danjuleixingList
      })
    }
    if (code == 'dingdanstate') {
      this.setData({
        popupShowIsok: true,
        activeCode: code,
        columns: this.data.dingdanStateList
      })
    }
    if (code == 'renwuleixing') {
      this.setData({
        popupShowIsok: true,
        activeCode: code,
        columns: this.data.renwuList
      })
    }
    if (code == 'paicheleixing') {
      this.setData({
        popupShowIsok: true,
        activeCode: code,
        columns: this.data.paicheList
      })
    }

  },
  postDataQuery_dynamic (postData) {
    return new Promise((resolve, reject) => {
      wx.$post(3, 'DynamicQuery/query_dynamic_v3', postData).then(res => { resolve(res) }).catch(err => { reject(err) })
    })
  }
})